package com.mxpio.webapp.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.mxpio.webapp.entity.MonitorServer;
import com.mxpioframework.security.annotation.Dict;
import com.mxpioframework.security.entity.BaseEntity;
import lombok.*;
import lombok.experimental.Accessors;
import org.springframework.beans.BeanUtils;

import javax.persistence.Entity;
import javax.persistence.Id;
import java.io.Serializable;
import java.util.Date;

/**
 * 服务器信息表现层对象
 */
@Entity
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@Builder
@Getter
@Setter
@ToString
@AllArgsConstructor
@NoArgsConstructor
public class MonitorServerVo extends BaseEntity {

    /**
     * 主键ID
     */
    @Id
    private String id;

    /**
     * IP地址
     */
    private String ip;

    /**
     * 服务器名
     */
    private String serverName;

    /**
     * 服务器摘要
     */
    private String serverSummary;

    /**
     * 服务器状态（0：离线，1：在线）
     */
    @Dict(dicCode = "MI_MONITOR_ONLINE")
    private String isOnline;

    /**
     * 离线次数
     */
    private Integer offlineCount;

    /**
     * 连接频率
     */
    private Integer connFrequency;

    /**
     * 操作系统名称
     */
    private String osName;

    /**
     * CPU使用率
     */
    private Double cpuUserPercent;

    /**
     * 内存使用率
     */
    private Double menUsedPercent;

    /**
     * 服务器负载
     */
    private Double loadAverage;

    /**
     * 下行带宽
     */
    private String downloadBps;

    /**
     * 上行带宽
     */
    private String uploadBps;

    /**
     * 监控环境
     */
    private String monitorEnv;

    /**
     * 监控分组
     */
    @Dict(dicCode = "MI_MONITOR_GROUP")
    private String monitorGroup;

    /**
     * MonitorServer转MonitorServerVo
     *
     * @param monitorServer
     * @return
     */
    public MonitorServerVo convertFor(MonitorServer monitorServer) {
        if (null != monitorServer) {
            BeanUtils.copyProperties(monitorServer, this);
        }
        return this;
    }

}
